package com.email.box.common.enums;

import java.util.Arrays;

/**
 * 同步状态枚举类
 * @author lixuan
 */
public enum SyncStatusEnum {
    //同步状态
    NO_ANY_TABLE(0, "未建表"),
    EXISTING_TABLE(1, "已建表"),
    CREATE_TABLE_ERROR(2, "建表失败"),
    FULL_SYNC_IS_BEING_PERFORMED(3, "正在全量同步"),
    FULL_SYNC_IS_COMPLETE(4, "全量同步完成"),
    FULL_SYNC_FAILED_PROCEDURE(5, "全量同步失败"),
    OPEN_THE_SCHEDULING(6, "开启调度"),
    STOP_SCHEDULING(7, "暂停调度"),
    SYNC_INCREMENTALLY(8, "正在增量同步"),
    FAILURE_TO_ENABLE_SCHEDULING(9, "开启调度失败");

    private int code;
    private String message;

    SyncStatusEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public static String getSyncStatusName(int code) {
        SyncStatusEnum messageEnum = SyncStatusEnum.getSyncStatusEnum(code);
        return messageEnum.getMessage();
    }

    public static SyncStatusEnum getSyncStatusEnum(int code) {
        return Arrays.stream(SyncStatusEnum.values()).filter(x -> x.code == code).findFirst().orElse(null);
    }

}
